<?php

	$username = "";
	$password = "";
	$tbl_name = "users";

	$con = mysql_connect("localhost","root","$username","$password");
				if (!$con)
				{
					die('Could not connect: ' . mysql_error());
				}
		
	mysql_select_db("rgfusion", $con);
			
	$myusername = $_POST['myusername'];
	$mypassword = $_POST['mypassword'];
	
	$myusername = stripslashes($myusername);
	$mypassword = stripslashes($mypassword);
	$myusername = mysql_real_escape_string($myusername);
	$mypassword = mysql_real_escape_string($mypassword);

	$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password=PASSWORD('$mypassword')";
	$result=mysql_query($sql);
	
	$count=mysql_num_rows($result);
	
	if($count==1)
	{
		$row = mysql_fetch_array($result);
		setcookie("user",$row["Id"] . "," . $row["Password"]);
		header("location:login_success.php");
	}
	else
	{
		echo "Wrong username or Password";
	}


?>














